<template>
  <van-cell class="article-item" :to="{
      name: 'article',
      params: {
        articleId: article.art_id
      }
    }">
    <!-- 文章列表项 -->
    <!-- 标题 -->
    <div slot="title" class="title van-multi-ellipsis--l2"> {{ article.title }}
    </div>
    <!-- 标题下的数据 -->
    <div slot="label">
      <!-- 下边的图片,只有三张图片的情况显示 -->
      <div v-if="article.cover.images.length === 3" class="cover-wrap">
        <div class="cover-item" v-for="(img,index) in article.cover.images"
          :key="index">
          <van-image class="cover-item-img" fit="cover" :src="img" />

        </div>
      </div>
      <div class="label-info-wrap">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.aomm_count }}</span>
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>

    </div>
    <!-- 标题右边的图片 只有有一张图片的情况显示 -->
    <van-image slot="default" v-if="article.cover.images.length === 1"
      class="right-cover" fit="cover" :src="article.cover.images[0]" />

  </van-cell>
</template>

<script>
export default {
  // 组件名称
  name: 'ArticleItem',
  // 局部注册的组件
  components: {},
  // 组件参数 接收来自父组件的数据
  props: {
    article: {
      type: Object,
      required: true
    }
  },
  // 组件状态值
  data () {
    return {

    }
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 生命周期钩子   注：没用到的钩子请自行删除
  // 初始化之后
  created () { },
  // 挂载之后
  mounted () {
  },
  // 组件方法
  methods: {}
}
</script>

<style scoped lang="less">
.article-item {
  .title {
    font-size: 32px;
    color: #3a3a3a;
  }

  .van-cell__value {
    flex: unset;
    width: 232px;
    height: 146px;
    padding-left: 25px;
  }

  .right-cover {
    width: 232px;
    height: 146px;
  }

  .label-info-wrap span {
    font-size: 22px;
    color: #b4b4b4;
    margin-right: 25px;
  }

  .cover-wrap {
    display: flex;
    padding: 30px 0;
    .cover-item {
      flex: 1;
      height: 146px;
      &:not(:last-child) {
        padding-right: 4px;
      }
      .cover-item-img {
        width: 100%;
        height: 146px;
      }
    }
  }
}
</style>
